#include <stdio.h>
#include <omp.h>

// equivalent 函数
void equivalent(double A[100][100][3])
{
    #pragma omp parallel for collapse(4)
    for (int i1 = 0; i1 < 25; ++i1)
    {
        for (int j1 = 0; j1 < 25; ++j1)
        {
            #pragma GCC unroll 4
            for (int i2 = 0; i2 < 4; ++i2)
            {
                #pragma GCC unroll 4
                for (int j2 = 0; j2 < 4; ++j2)
                {
                    #pragma GCC unroll 3
                    for (int k = 0; k < 3; ++k)
                    {
                        int i = i1 * 4 + i2;
                        int j = j1 * 4 + j2;
                        A[i][j][k] = A[i][j][k] + 1;
                    }
                }
            }
        }
    }
}

int main()
{
    double A[100][100][3];

    // 初始化数组元素为 0
    for (int i = 0; i < 100; ++i)
    {
        for (int j = 0; j < 100; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                A[i][j][k] = 0;
            }
        }
    }

    // 调用 equivalent 函数
    equivalent(A);

    // 输出部分元素来验证结果
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                printf("A[%d][%d][%d] = %.2f\n", i, j, k, A[i][j][k]);
            }
        }
    }

    return 0;
}    